<template>
    <h2>注册页面</h2>
    <table border="0" cellspacing="0" cellpadding="10" style="background-color:aquamarine;color:white;">
        <tr>
            <td colspan="2" align="center">注册</td>

        </tr>

        <tr>
            <td>手机号</td>
            <td><input type="text" v-model="List.phone"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" v-model="List.password"></td>
        </tr>
        <tr>
            <td>确认密码</td>
            <td><input type="password" v-model="List.password1"></td>
        </tr>
        <tr>

            <td><button @click="Login">注册</button></td>
            <td><button>使用邮箱注册</button></td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router';

const router = useRouter();


import { ref } from 'vue';

const List = ref({
    phone: '',
    password: '',
    password1: ''

})
const Login = () => {
    console.log(List.value.phone)
    console.log(List.value.password)
    console.log(List.value.password1)
    if (List.value.phone == "" || List.value.password == "" || List.value.password1 == "") {
        alert("用户输入的内容不允许为空");
        return;
    }
    if (List.value.phone.length != 11) {
        alert("请输入11位手机号");
        return;
    }
    if (List.value.password != List.value.password1) {
        alert("两次输入的密码不一致");
        return;
    }
    if (List.value.phone != '13512349876') {
        alert("用户输入的手机号必须是“13512349876”")
        return;
    }
    if (List.value.password != '123456') {
        alert("用户输入的密码必须是“123456”")
        return;
    }

    if (List.value.password == List.value.password1) {
        console.log('注册成功');
        router.push({
            path: "/Show",
            query: {
                phone: List.value.phone

            }

        });

    } else {
        console.log('注册失败')
    }
}

</script>
<style scoped></style>